package com.example.firstspringboot.result;

/**
 * <p>状态类 Result 的枚举类</p>
 */
public enum ResultCode {
    /**
     * <p>状态码</p>
     */
    SUCCESS(200, "成功"),
    FAIL(-1, "失败"),
    NOT_FOUND(404, "资源不存在"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错"),

    /**
     * <p>自定义的状态码(码值是自拟)</p>
     */
    ID_NOT_FOUND(4001, "id不存在"),
    ID_DUPLICATED(4002, "id重复");

    private int code;
    private String message;

    ResultCode(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
